from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1.endpoint import crawler, test, generate, analysis, send

app = FastAPI(title="舆情爬虫API")

# Add CORS middleware
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 注册路由
app.include_router(crawler.router, prefix="/api/v1/crawler", tags=["爬虫相关接口"])
app.include_router(analysis.router, prefix="/api/v1/analysis", tags=["分析相关接口"])
app.include_router(generate.router, prefix="/api/v1/generate", tags=["内容生成相关接口"])
app.include_router(send.router, prefix="/api/v1/send", tags=["发送相关接口"])
app.include_router(test.router, prefix="/api/v1/test", tags=["测试相关接口"])


if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="127.0.0.1", port=8000)